home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9229 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: presby.edu!jtbell
  3. From: jtbell@presby.edu (Jon Bell)
  4. Subject: Re: How does the c++ compiler handle references?
  5. Message-ID: <DnJJrL.AAv@presby.edu>
  6. Date: Thu, 29 Feb 1996 14:18:56 GMT
  7. References: <4h3ld1$jd1@taco.cc.ncsu.edu>
  8. Organization: Presbyterian College, Clinton, South Carolina USA
  9.  
  10.  John Kirk Hammond <jkhammon@unity.ncsu.edu> wrote:
  11. >
  12. >    void test(short &hello)
  13. >    {
  14. >        hello++;
  15. >    }
  16.  
  17. >    Does the compiler do some sort of funky pointer weirdness?
  18. >Like sending the address of hello instead of the value to test and
  19. >casting the short parameter in test to a short *?  And then
  20. >treating all uses of the variable hello in test as the dereferenced
  21. >pointer?
  22.  
  23. Yup, that's exactly what happens.  References are basically pointers that 
  24. you can't change (i.e. point them to something different) and that are 
  25. always implicitly dereferenced.
  26.  
  27. And what's funky and weird about it?  They look just like "var" 
  28. parameters in Pascal to me.  :-)
  29.  
  30. -- 
  31. Jon Bell <jtbell@presby.edu>            |  "The Internet grows hyper-
  32. Dept. of Physics and Computer Science   |  bolically, but is usually 
  33. Presbyterian College                    |  described elliptically."
  34. Clinton, South Carolina USA             |       -- Dr. Internet
  35.